#ifndef MASTERPANELFORM_H
#define MASTERPANELFORM_H

#include <QWidget>
#include <QThread>
#include "common/DataType.h"
#include "link/ModBusTcpWorker.h"

namespace Ui {
class MasterPanelForm;
}

class MasterPanelForm : public QWidget
{
    Q_OBJECT

public:
    explicit MasterPanelForm(QWidget *parent = nullptr);
    ~MasterPanelForm();
    void setProNameDevType(QString proName,int devType);
    void setIPPort(QString address,short port);
    void setReadStartAddressAndRegisterCount(QList<int> startAddress, QList<int> registerCount,int RegisterType);

    void startLoopReadRegister(bool isStart);


signals:
    /***type  0:主机  1:从机1   2:从机2  3:从机3 ...  ***/
    void sig_SetProNameDevType(QString proName,int devType);

    void sig_SetIPPort(QString address,short port);

    void sig_SetReadStartAddressAndRegisterCount(QList<int> startAddress, QList<int> registerCount,int RegisterType);
    void sig_StartLoopReadRegister(bool start);

    //写寄存器的数据
    void sig_WriteRegister(WriteData *data);

    //发送分机故障
    void sig_Dev1fault(bool faultBool);//
    void sig_Dev2fault(bool faultBool);//
    void sig_Dev3fault(bool faultBool);//
    void sig_Dev4fault(bool faultBool);//
    void sig_Dev5fault(bool faultBool);//
    void sig_Dev6fault(bool faultBool);//
    void sig_Dev7fault(bool faultBool);//
    void sig_Dev8fault(bool faultBool);//



protected slots:
    void slot_ConnectionState(bool State);

    //最终界面显示的浮点数
    void slot_ReadfloatData(int MsgId,QList<float> data);

    //最终界面显示的bool
    void slot_ReadBoolData(int MsgId,QList<bool> data);


private slots:
    void on_btnHighFre_clicked();

    void on_btnLowFre_clicked();

    void on_btnReset_clicked();

private:
    Ui::MasterPanelForm *ui;

    QThread* m_Thread;
    ModBusTcpWorker* m_ModBusTcpWorker;//通信

    quint16 readData1;//记录接收的一个modbus数据点位

};

#endif // MASTERPANELFORM_H
